import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  //登录页面暂时不启用
  // {
  //   path: "/login",
  //   name: "login",
  //   meta: {
  //     title: "login",
  //     keepAlive: false,
  //     tokenId: true,
  //   },
  //   component: () => import("@/views/login/login.vue"),
  // },
  // 父路由
  {
    path: "/",
    name: "admin",
    component: () => import("./views/admin/Admin.vue"),
    // 父路由
    // 子路由
    children: [
      {
        path: "/navigation",
        name: "navigation",
        component: () => import("@/views/srdemo/navigation/navigation.vue"),
      },
      {
        path: "/platform",
        name: "platform",
        component: () => import("@/views/srdemo/platform/platform.vue"),
      },
      {
        path: "/friendlink",
        name: "friendlink",
        component: () => import("@/views/srdemo/friendlink/friendlink.vue"),
      },
      {
        path: "/contact-way",
        name: "联系方式",
        component: () => import("./views/contact-way/contact.vue"),
      },
      {
        path: "/video",
        alias: "/",
        name: "宣传视频",
        component: () => import("./views/video/video.vue"),
      },
      {
        path: "/partner",
        name: "partner",
        component: () => import("@/views/partner/partner.vue"),
      },
      {
        path: "/table",
        name: "table",
        component: () => import("@/views/table/table.vue"),
      },
      {
        path: "/detail",
        name: "详情页",
        component: () => import("./views/detail-page/detail.vue"),
      },
      {
        path: "/Rotating_map_configuration",
        name: "轮播图",
        component: () => import("./views/lbtpz/Lbtpz.vue"),
      },
    ],
    // 子路由
  },
];

// 路由重读点击报错
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};

const router = new VueRouter({
  mode: "history",
  routes,
});


/*
 * 路由守卫 
 * @param {to} 将要去的路由
 * @param {from} 出发的路由
 * @param {next} 执行下一步
 */
router.beforeEach((to, from, next) => {
  next()
})
export default router;
